<template>
	<view class="yc_main">
		<view class="bg_ff">
			<view class="common_width">
				<view class="blank_box_mini"></view>
				<u-divider text="密码修改" textSize="16"></u-divider>
				<view class="common_form">
					<view class="form_item space_between">
						<view class="label">原密码 </view>

						<view class="content">
							<input type="password" v-model="form.orgPassword" class="pct100 tr" maxlength="20" />
						</view>
					</view>
					<view class="form_item space_between">
						<view class="label">新密码 </view>

						<view class="content">
							<input type="password" v-model="form.password" class="pct100 tr" maxlength="20" />
						</view>
					</view>
					<view class="form_item space_between">
						<view class="label">确认密码 </view>

						<view class="content">
							<input type="password" v-model="form.repassword" class="pct100 tr" maxlength="20" />
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="p40">
			<view class="p20">
				<u-button type="primary" @click="submit">提交</u-button>
			</view>
			<view class="p20">
				<u-button type="error" @click="exit">退出</u-button>
			</view>
		</view>
	</view>
</template>

<script>
let tagInfo = "[/pages/.vue]";
import basePage from "@/libs/base-page.js";
import Manager from "../../libs/model/manager";
export default {
	//name: "index-me",
	mixins: [basePage],
	data() {
		return {
			value1: "11:00",
			show: false,
			form: {
				orgPassword: "",
				password: "",
				repassword: ""
			}
		};
	},
	onLoad() {
		this.checkLogin();
		this.loadData();
	},
	methods: {
		async loadData() {
			//this.initSaveData();
		},
		async submit() {
			let that = this;
			let res = await Manager.changePassword(this.form.orgPassword, this.form.password, this.form.repassword);
			if (res.code != 0) {
				this._util.message.alert(res.msg);
				return;
			}
			uni.showModal({
				content: "修改成功，请重新登录 ",
				showCancel: false,
				success: (res) => {
					if (res.confirm) {
						that._util.storage.remove("token");
						uni.reLaunch({
							url: "/pages/index/index"
						});
					}
				}
			});
		},
		async exit() {
			let res = await this._util.message.confirm("提示", "确定要退出吗？");
			if (!res) {
				return;
			}
			res = Manager.loginOut();
			if (res.code != 0) {
				this._util.message.alert(res.msg);
				return;
			}
			uni.reLaunch({
				url: "/pages/index/index"
			});
		}
	}
};
</script>

<style lang="scss" scoped>
</style>
